set(PROTO_SOURCE atomic_incr.proto)
execute_process(COMMAND ${PROTOBUF_PROTOC} 
  -I${CMAKE_CURRENT_SOURCE_DIR} 
  --cpp_out=${CMAKE_CURRENT_SOURCE_DIR} 
  ${PROTO_SOURCE}
)

foreach(SRV_OR_CLT server client)
  set(TARGET_NAME "")
  string(APPEND TARGET_NAME atomic_ ${SRV_OR_CLT})
  set(EXAMPLE_SOURCE "")
  string(APPEND EXAMPLE_SOURCE atomic_incr_ ${SRV_OR_CLT} ".cpp")
  add_executable(${TARGET_NAME} ${EXAMPLE_SOURCE} atomic_incr.pb.cc)
  target_link_directories(${TARGET_NAME}
    PRIVATE ${STAGED_INSTALL_PREFIX}/lib
  )
  target_link_libraries(${TARGET_NAME}
    PRIVATE rpc
  )
endforeach()